function loadJS( filePath, callback ){
	var url = "chrome-extension://"+chrome.runtime.id+"/"+filePath;
	debugger;
    var script = document.createElement('script'),
        fn = callback || function(){};
    script.type = 'text/javascript';    

    // IE
    if(script.readyState){
        script.onreadystatechange = function(){
            if( script.readyState == 'loaded' || script.readyState == 'complete' ){
                script.onreadystatechange = null;
                fn();
            }
        };
    }else{
        // 其他浏览器
        script.onload = function(){
            fn();
        };
    }
    script.src = url;
    document.getElementsByTagName('head')[0].appendChild(script);
}

// 向页面注入JS
function injectCustomJs(filePath, callback)
{
	var url = "chrome-extension://"+chrome.runtime.id+"/"+filePath;
	fn = callback || function(){};
	// jsPath = jsPath || 'js/inject.js';
	var temp = document.createElement('script');
	temp.setAttribute('type', 'text/javascript');
	// 获得的地址类似：chrome-extension://ihcokhadfjfchaeagdoclpnjdiokfakg/js/inject.js
	temp.src = chrome.extension.getURL(filePath);
	// debugger;
	temp.onload = function()
	{
		// 放在页面不好看，执行完后移除掉
		// this.parentNode.removeChild(this);
		fn();
	};
	document.head.appendChild(temp);
}

document.addEventListener('DOMContentLoaded', function()
{
	var jsName="js/"+window.location.host+".js"
	console.log('当前域名',window.location.host);
	injectCustomJs(jsName,function(){
		console.log('加载js',jsName);
		if(window.doInterceptor)window.doInterceptor();
	});
});